import React, { Component } from 'react'
import { connect } from 'dva';
import FormList from '../components/FormItem';

interface Props {
  dispatch: Function,
  data: {
    id: number
  },
  match: {
    params: {
      id: number
    }
  },
  details: object
}

const Keys = [
  'id',
  'name', 
  'remark', 
]

@connect(({ role }) => ({
  data: role.editDetails
}))
class Update extends Component<Props, any> {

  componentDidMount() {
    const { dispatch, match } = this.props;
    const { params } = match;

    dispatch({
      type: 'role/queryEditInfoById',
      payload: {
        id: params.id,
        keys: Keys
      }
    })
  }

  render() {
    return (
      <>
        <FormList data={this.props.data} key={Date.now()}/>
      </>
    );
  }
}

export default Update;